package com.changhongit.service.wemeet;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.changhongit.utils.RequestSenderUtil;
import com.tencentcloudapi.wemeet.client.UserClient;
import com.tencentcloudapi.wemeet.common.exception.WemeetSdkException;

import com.tencentcloudapi.wemeet.models.user.QueryUserDetailRequest;
import com.tencentcloudapi.wemeet.models.user.QueryUserDetailResponse;
import com.tencentcloudapi.wemeet.models.user.QueryUsersRequest;
import com.tencentcloudapi.wemeet.models.user.QueryUsersResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class WeUserService {
    private static final Log log = LogFactory.getLog(WeUserService.class);
    private static final Gson GSON = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
    @Autowired
    RequestSenderUtil sender;

    public QueryUsersResponse QueryListUsers() throws WemeetSdkException {
        UserClient userClient = new UserClient(sender.getProfile());
        QueryUsersRequest queryUsersRequest = new QueryUsersRequest();
        queryUsersRequest.setPageSize(20);
        queryUsersRequest.setPage(1);
        QueryUsersResponse response = userClient.queryUsers(queryUsersRequest);
        log.info(GSON.toJson(response));

        return response;
    }

    public QueryUserDetailResponse queryUserDetailResponsebyid(String id) throws WemeetSdkException{
        UserClient userClient = new UserClient(sender.getProfile());
        QueryUserDetailRequest request = new QueryUserDetailRequest();
        request.setUserId(id);
        QueryUserDetailResponse response = userClient.queryUserDetail(request);
        log.info(GSON.toJson(response));

        return response;


    }



}
